package org.csmzxy.class2333;
public class Example04 {
    public static void main(String[] args) {
        // 分别创建两个 Thread 线程对象
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()
                        + "正在输出 i：" + i);
            }
        }, "优先级较低的线程");
        Thread thread2 = new Thread(() -> {
            for (int j = 0; j < 5; j++) {
                System.out.println(Thread.currentThread().getName()
                        + "正在输出 j：" + j);
            }
        }, "优先级较高的线程");
        // 分别设置线程的优先级
        thread1.setPriority(Thread.MIN_PRIORITY);
        thread2.setPriority(10);
        // 启动两个线程
        thread1.start();
        thread2.start();
    }
}